import http from './http.js'

/**
 * 采购工作台API服务
 */
export const procurementApi = {
  /**
   * 获取采购工作台统计数据
   * 包括采购完成率、订单数、采购金额、供应商数量、库存价值、质检合格率
   */
  getProcurementStatistics() {
    return http.get('/intelligent-workbench/procurement/statistics')
  },

  /**
   * 获取采购待办事项
   * 包括待审核采购申请、待确认订单、逾期订单、质检异常等
   */
  getProcurementTodos() {
    return http.get('/intelligent-workbench/procurement/todos')
  },

  /**
   * 获取采购趋势数据
   * 包括年度目标、本月目标、采购趋势等
   */
  getProcurementTrends() {
    return http.get('/intelligent-workbench/procurement/trends')
  },

  /**
   * 获取采购订单列表
   * @param {Object} params 查询参数
   * @param {number} params.page 页码
   * @param {number} params.pageSize 每页数量
   * @param {string} params.keyword 关键词
   * @param {string} params.status 订单状态
   * @param {string} params.expectedDate 期望到货时间
   */
  getProcurementOrders(params = {}) {
    return http.get('/intelligent-workbench/procurement/orders', {
      params: {
        page: params.page || 1,
        pageSize: params.pageSize || 10,
        keyword: params.keyword || '',
        status: params.status || '',
        expectedDate: params.expectedDate || ''
      }
    })
  },

  /**
   * 获取供应商列表
   */
  getSuppliers() {
    return http.get('/intelligent-workbench/procurement/suppliers')
  },

  /**
   * 获取采购订单详情
   * @param {number} orderId 订单ID
   */
  getProcurementOrderDetail(orderId) {
    return http.get(`/intelligent-workbench/procurement/orders/${orderId}`)
  }
}

export default procurementApi